<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <#assign base=request.contextPath  />
    <base id="base" href="${base}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, adminUser-scalable=0">
    <link rel="stylesheet" href="${base}/static/win10/component/layui/css/layui.css" media="all">
    <script>
        var base =  "${base}";
    </script>
</head>
<body>
<br>
<form class="layui-form " action="">
         <input type="hidden" id="id" name="id" value="${orderbus.id!?c}" >
          <div class="layui-form-item">
              <label class="layui-form-label">全款订单单号</label>
              <div class="layui-input-block">
                  <input type="text" id="ordernum" name="ordernum" value="${orderbus.ordernum!}"  autocomplete="off" placeholder="请输入全款订单单号"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">定金单号</label>
              <div class="layui-input-block">
                  <input type="text" id="dingjinNum" name="dingjinNum" value="${orderbus.dingjinNum!}"  autocomplete="off" placeholder="请输入定金单号"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">尾款单号</label>
              <div class="layui-input-block">
                  <input type="text" id="weikuanNum" name="weikuanNum" value="${orderbus.weikuanNum!}"  autocomplete="off" placeholder="请输入尾款单号"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">下单时间</label>
              <div class="layui-input-block">
                  <input type="text" id="ordertime" readonly  name="ordertime"   autocomplete="off" placeholder="请输入下单时间"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">姓名</label>
              <div class="layui-input-block">
                  <input type="text" id="username" name="username" value="${orderbus.username!}"  autocomplete="off" placeholder="请输入姓名"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">手机号</label>
              <div class="layui-input-block">
                  <input type="text" id="phone" name="phone" value="${orderbus.phone!}"  autocomplete="off" placeholder="请输入手机号"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">选择时间</label>
              <div class="layui-input-block">
                  <input type="text" id="choosetime" name="choosetime" value="${orderbus.choosetime!}"  autocomplete="off" placeholder="请输入选择时间"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">上站地点</label>
              <div class="layui-input-block">
                  <textarea readonly id="stationup">"${orderbus.stationup!}" </textarea>
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">下站地点</label>
              <div class="layui-input-block">
                  <textarea readonly id="stationdown">"${orderbus.stationdown!}" </textarea>
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">人数</label>
              <div class="layui-input-block">
                  <input type="text" id="peoplenumber" name="peoplenumber" value="${orderbus.peoplenumber!}"  autocomplete="off" placeholder="请输入人数"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">订单状态 </label>
              <div class="layui-input-block">

                  <select id="status" lay-filter="status">
                      <option value="">请选择....</option>
                      <option value="0">待确认</option>
                      <option value="1">已确认待付款</option>
                      <option value="2">进行中</option>
                      <option value="3">已结束</option>
                  </select>
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">用户id</label>
              <div class="layui-input-block">
                  <input type="text" id="userid" name="userid" value="${orderbus.userid!}"  autocomplete="off" placeholder="请输入用户id"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">备注</label>
              <div class="layui-input-block">
                  <input type="text" id="beizhu" name="beizhu" value="${orderbus.beizhu!}"  autocomplete="off" placeholder="请输入备注"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">全款金额</label>
              <div class="layui-input-block">
                  <input type="text" id="jine" name="jine" value="${orderbus.jine!}"  autocomplete="off" placeholder="请输入全款金额"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">尾款金额</label>
              <div class="layui-input-block">
                  <input type="text" id="weikuan" name="weikuan" value="${orderbus.weikuan!}"  autocomplete="off" placeholder="请输入尾款金额"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">定金金额</label>
              <div class="layui-input-block">
                  <input type="text" id="dingjin" name="dingjin" value="${orderbus.dingjin!}"  autocomplete="off" placeholder="请输入定金金额"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">租车用途</label>
              <div class="layui-input-block">
                  <input type="text" id="yongtu" name="yongtu" value="${orderbus.yongtu!}"  autocomplete="off" placeholder="请输入租车用途"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">已支付金额</label>
              <div class="layui-input-block">
                  <input type="text" id="payMoney" name="payMoney" value="${orderbus.payMoney!}"  autocomplete="off" placeholder="请输入已支付金额"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">支付状态 </label>
              <div class="layui-input-block">

                  <select id="payStatus" lay-filter="payStatus">
                      <option value="">请选择....</option>
                      <option value="0">未支付</option>
                      <option value="1">仅支付定金</option>
                      <option value="2">支付完毕(全款)</option>
                  </select>
              </div>
          </div>
       <#--   <div class="layui-form-item">
              <label class="layui-form-label">定金支付时间</label>
              <div class="layui-input-block">
                  <input type="text" id="paytime1" name="paytime1" value="${orderbus.paytime1!}"  autocomplete="off" placeholder="请输入定金支付时间"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">全款支付时间</label>
              <div class="layui-input-block">
                  <input type="text" id="paytime2" name="paytime2" value="${orderbus.paytime2!}"  autocomplete="off" placeholder="请输入全款支付时间"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">尾款支付时间</label>
              <div class="layui-input-block">
                  <input type="text" id="paytime3" name="paytime3" value="${orderbus.paytime3!}"  autocomplete="off" placeholder="请输入尾款支付时间"
                         class="layui-input">
              </div>
          </div>-->
          <div class="layui-form-item">
              <label class="layui-form-label">支付类型 </label>
              <div class="layui-input-block">
                  <select id="payType" lay-filter="payType">
                      <option value="">请选择....</option>
                      <option value="-1">没有支付</option>
                      <option value="0">定金+尾款支付</option>
                      <option value="1">全款直接支付</option>
                  </select>
              </div>
          </div>

    <div align="center">
        <button type="button" class="layui-btn" id="submit">保存</button>
    </div>
</form>

<script src="${base}/static/win10/component/layui/layui.js?t=1"></script>
<script src="${base}/static/win10/js/jquery-1.8.3.min.js?t=1"></script>
<script src="${base}/static/win10/js/zhang.js?t=1"></script>
<script>
    var stationupJson='${orderbus.stationup!}';
    if(stationupJson!=null&&stationupJson!=""){
        stationupJson=JSON.parse(stationupJson);
        $("#stationup").val("地点："+stationupJson.address+" \n 经度："+stationupJson.latitude+" \n 纬度："+stationupJson.longitude)
    }
    var stationdownJson='${orderbus.stationdown!}';
    if(stationdownJson!=null&&stationdownJson!=""){
        stationdownJson=JSON.parse(stationdownJson);
        $("#stationdown").val("地点："+stationdownJson.address+" \n 经度："+stationdownJson.latitude+" \n 纬度："+stationdownJson.longitude)
    }
    layui.use(['form', 'layer','laydate'], function() {
        var form = layui.form
                , layer = layui.layer;
        var laydate = layui.laydate;
        if("${orderbus.paytime3!}"!=null&&"${orderbus.paytime3!}"!=""){
            $("#paytime3").val(changeDateFormat("${orderbus.paytime3!}"))
        }

        if("${orderbus.paytime2!}"!=null&&"${orderbus.paytime2!}"!=""){
            $("#paytime2").val(changeDateFormat("${orderbus.paytime2!}"))
        }

        if("${orderbus.paytime1!}"!=null&&"${orderbus.paytime1!}"!=""){
            $("#paytime1").val(changeDateFormat("${orderbus.paytime1!}"))
        }
        if("${orderbus.ordertime!}"!=null&&"${orderbus.ordertime!}"!=""){
            $("#ordertime").val(changeDateFormat("${orderbus.ordertime!}"))
        }
        var payStatus="${orderbus.payStatus!}";
        $("#payStatus").val(payStatus)
        var status="${orderbus.status!}";
        $("#status").val(status)
        var payType="${orderbus.payType!}";
        $("#payType").val(payType)

        form.render();

        laydate.render({
            elem: '#paytime3' //或 elem: document.getElementById('test')、elem: lay('#test') 等
            ,type: 'datetime'

        });
        laydate.render({
            elem: '#paytime2' //或 elem: document.getElementById('test')、elem: lay('#test') 等
            ,type: 'datetime'
        });

        laydate.render({
            elem: '#paytime1' //或 elem: document.getElementById('test')、elem: lay('#test') 等
            ,type: 'datetime'
        });

        laydate.render({
            elem: '#choosetime' //或 elem: document.getElementById('test')、elem: lay('#test') 等
            ,type: 'datetime'
        });


        $("#submit").on("click",function () {
        /*    if(check()===false){
                return;
            }*/

            var formDate = {
                         id:$("#id").val(),
                         ordernum:$("#ordernum").val(),
                         dingjinNum:$("#dingjinNum").val(),
                         weikuanNum:$("#weikuanNum").val(),
                         username:$("#username").val(),
                         phone:$("#phone").val(),
                         choosetime:$("#choosetime").val(),
                         peoplenumber:$("#peoplenumber").val(),
                         status:$("#status").val(),
                         userid:$("#userid").val(),
                         beizhu:$("#beizhu").val(),
                         jine:$("#jine").val(),
                         weikuan:$("#weikuan").val(),
                         dingjin:$("#dingjin").val(),
                         yongtu:$("#yongtu").val(),
                         payMoney:$("#payMoney").val(),
                         payStatus:$("#payStatus").val(),
                         paytime1:$("#paytime1").val(),
                         paytime2:$("#paytime2").val(),
                         paytime3:$("#paytime3").val(),
                           payType:$("#payType").val()
            }
            $.ajax({
                type: "POST",
                url: base+"/bus/orderbus/editOrderbus",
                data: formDate,
                success: function (data) {
                    layer.msg(data.message)
                    if (data.code === 200) {
                        window.location.href=base+"/bus/orderbus/main.html"
                    } else {

                    }
                }
            });
        })







        function check(){
                   if($("#ordernum").val().length<1){
                       layer.msg("请输入全款订单单号");
                       return false;
                   }
                   if($("#dingjinNum").val().length<1){
                       layer.msg("请输入定金单号");
                       return false;
                   }
                   if($("#weikuanNum").val().length<1){
                       layer.msg("请输入尾款单号");
                       return false;
                   }
                   if($("#ordertime").val().length<1){
                       layer.msg("请输入下单时间");
                       return false;
                   }
                   if($("#username").val().length<1){
                       layer.msg("请输入姓名");
                       return false;
                   }
                   if($("#phone").val().length<1){
                       layer.msg("请输入手机号");
                       return false;
                   }
                   if($("#choosetime").val().length<1){
                       layer.msg("请输入选择时间");
                       return false;
                   }
                   if($("#stationup").val().length<1){
                       layer.msg("请输入上站地点");
                       return false;
                   }
                   if($("#stationdown").val().length<1){
                       layer.msg("请输入下站地点");
                       return false;
                   }
                   if($("#peoplenumber").val().length<1){
                       layer.msg("请输入人数");
                       return false;
                   }
                   if($("#status").val().length<1){
                       layer.msg("请输入订单状态0-待确认 1-已确认待付款 2-进行中 3-已结束 ");
                       return false;
                   }
                   if($("#userid").val().length<1){
                       layer.msg("请输入用户id");
                       return false;
                   }
                   if($("#beizhu").val().length<1){
                       layer.msg("请输入备注");
                       return false;
                   }
                   if($("#jine").val().length<1){
                       layer.msg("请输入全款金额");
                       return false;
                   }
                   if($("#weikuan").val().length<1){
                       layer.msg("请输入尾款金额");
                       return false;
                   }
                   if($("#dingjin").val().length<1){
                       layer.msg("请输入定金金额");
                       return false;
                   }
                   if($("#yongtu").val().length<1){
                       layer.msg("请输入租车用途");
                       return false;
                   }
                   if($("#payMoney").val().length<1){
                       layer.msg("请输入已支付金额");
                       return false;
                   }
                   if($("#payStatus").val().length<1){
                       layer.msg("请输入支付状态0=未支付 1=仅支付定金 2=支付完毕(全款) ");
                       return false;
                   }
                   if($("#paytime1").val().length<1){
                       layer.msg("请输入定金支付时间");
                       return false;
                   }
                   if($("#paytime2").val().length<1){
                       layer.msg("请输入全款支付时间");
                       return false;
                   }
                   if($("#paytime3").val().length<1){
                       layer.msg("请输入尾款支付时间");
                       return false;
                   }
                   if($("#payType").val().length<1){
                       layer.msg("请输入支付类型 -1 没有支付 0定金+尾款支付 1全款直接支付");
                       return false;
                   }
        }
    });

</script>
</body>
</html>